package com.yonyou.pmclouds.projectpart.processor;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.projectpart.entity.ProjectPartVO;
import org.apache.commons.lang.ArrayUtils;
import org.springframework.stereotype.Component;

/**
 * 工程部位删除检查
 */
@Component
public class ProjectpartDeleteCheckProcessor implements SingleProcessor<ProjectPartVO>{

    @Override
    public void process(ProjectPartVO vo, ProjectPartVO orig) throws BusinessException {
        if("topVirtual".equals(vo.getScode())){
            throw new BusinessException("虚拟根节点不允许删除");
        }
        if(!ArrayUtils.isEmpty(vo.getChildProjectpart())){
            throw new BusinessException("非末级节点，不允许删除");
        }
    }
}
